﻿@model IEnumerable<FILSTARTUPS_CMS.Models.Role>
@{
    ViewBag.Title = "Index";
}
@section Pagename
{
<h2>Role</h2>
}
<!--- Twitter link update --->
<div id="commonMessage"></div>
@if (TempData["message"] != null)
{
<div class="alert-message success" id="tempdata"><center>@TempData["message"]</center></div>
}

<div class="row">
<div id="rolename" class="span3">
<h2>Options</h2>
    <ul>
        <li>@Html.ActionLink("Add User","Create","User")</li>
        <li>@Html.ActionLink("Add Role","Create","Role")</li>
    </ul>
</div>
<div class="span11">
@Html.Partial("_RoleList")
</div>


</div>



@*<div id="updateDialog" title="Update Role"></div>
<script type="text/javascript">
    var linkObj;
    $(function () {
        $(".editLink").button();

        $('#updateDialog').dialog({
            autoOpen: false,
            width: 400,
            resizable: false,
            modal: true,
            buttons: {
                "Update": function () {
                    $("#update-message").html(''); //make sure there is nothing on the message before we continue                         
                    $("#updateRoleForm").submit();
                },
                "Cancel": function () {
                    $(this).dialog("close");
                }
            }
        });

        $(".editLink").click(function () {
            //change the title of the dialgo
            linkObj = $(this);
            var dialogDiv = $('#updateDialog');
            var viewUrl = linkObj.attr('href');
            $.get(viewUrl, function (data) {
                dialogDiv.html(data);
                //validation
                var $form = $("#updateRoleForm");
                // Unbind existing validation
                $form.unbind();
                $form.data("validator", null);
                // Check document for changes
                $.validator.unobtrusive.parse(document);
                // Re add validation with changes
                $form.validate($form.data("unobtrusiveValidation").options);
                //open dialog
                dialogDiv.dialog('open');
            });
            return false;
        });

    });


    function updateSuccess() {
        if ($("#update-message").html() == "True") {
            //we update the table's info
            var parent = linkObj.closest("tr");
            parent.find(".rolename").html($("#Rolename").val());
            parent.find(".roledescription").html($("#RoleDescription").val());
            //now we can close the dialog
            $('#updateDialog').dialog('close');
            //twitter type notification
            $('#commonMessage').html("Update Complete");
            $('#commonMessage').delay(400).slideDown(400).delay(3000).slideUp(400);
        }
        else {
            $("#update-message").show();
        }
    }
    
</script>
*@